<template>
  <div class="mittB">
    <h4>我是组件B(发送方)</h4>
    <button @click="fabu">发布通知</button>

    <input :value="modelValue" @input="updateValue" />
  </div>
</template>

<script setup lang="ts">
import Bus from "@/utils/EventBus";
import {defineProps, defineEmits} from "vue";
// 定义接收的props和发出的事件
const props = defineProps({
  modelValue: String,
});
const emit = defineEmits(["update:modelValue"]);

// 更新父组件的值
const updateValue = (event: any) => {
  emit("update:modelValue", event.target.value);
};

const fabu = () => {
  Bus.emit("message", "大家国庆记得玩的开心！");
};
</script>

<style lang="scss" scoped>
.mittB {
  border: 2px solid hotpink;
  width: 200px;
  height: 200px;
  text-align: center;
}
</style>
